import requests
from bs4 import BeautifulSoup
import csv
url = 'https://desk.zol.com.cn/chemo/'

head = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.102 Safari/537.36 Edg/98.0.1108.56'
}
data = requests.get(url, headers=head)
data.encoding = 'gb2312'

soup = BeautifulSoup(data.text, 'html.parser')
data.close()

data = soup.find("ul", class_=["pic-list2", "clearfix"])

table =data.find_all("a", class_="pic")

# 高清图片地址
# print('https://desk.zol.com.cn'+table[1].get('href'))
# 获取缩图片
# print(table[1].img)
# 简写
# print(soup.select('img'))

i=0
for x in table:
  imgurl =table[i].img.get('src')
  i=i+1

  img_dowloads= requests.get(imgurl)
  img_name =imgurl.split("/")[-1]
  print(img_name)
  with open("img/"+img_name,mode="wb") as f:
      f.write(img_dowloads.content)





